package com.cskaoyan.app.wxservice.impl;

import com.cskaoyan.app.bean.common.CommonData;
import com.cskaoyan.app.bean.po.MarketIssue;
import com.cskaoyan.app.bean.po.MarketIssueExample;
import com.cskaoyan.app.mapper.MarketIssueMapper;
import com.cskaoyan.app.wxservice.WxIssueService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WxIssueServiceImpl implements WxIssueService {

    @Autowired
    private MarketIssueMapper mapper;

    @Override
    public CommonData<MarketIssue> list(Integer page, Integer limit) {
        if (page != null && limit != null) {
            PageHelper.startPage(page, limit);
        }
        MarketIssueExample example = new MarketIssueExample();
        MarketIssueExample.Criteria criteria = example.createCriteria();
        criteria.andDeletedEqualTo(false);
        List<MarketIssue> issues = mapper.selectByExample(example);
        PageInfo<MarketIssue> pageInfo = new PageInfo<>(issues);
        return CommonData.data(pageInfo);
    }
}
